home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Applications / UIFlow 1.0.1 / UIFlow Source / CFDFront / TObstacle.cp < prev    next >
Encoding:
Text File  |  1992-02-21  |  3.0 KB  |  90 lines  |  [TEXT/MPS ]

  1. #pragma segment Boundry
  2. // **********************************************************************
  3. //    TObstacle Class
  4. //        The obstacle objects
  5. // **********************************************************************
  6. // --------------------------------------------------------------------------------------------------
  7. //    TObstacle    :    Initialize the Class
  8. // --------------------------------------------------------------------------------------------------
  9. void TObstacle::IObstacle(PointInfo * info)
  10.     {
  11.     fUpLeft        =    info->oPt;
  12.     fUpRight    =     info->above;
  13.     fLwLeft    =    info->left;
  14.     fLwRight    =     info->below;
  15.     
  16.     this->SetObstacle();
  17.     return;
  18.     }
  19.  
  20. // --------------------------------------------------------------------------------------------------
  21. //    TObstacle    :    Initialize the Class
  22. // --------------------------------------------------------------------------------------------------
  23. void TObstacle::SetCorners(PointInfo * info)
  24.     {
  25.     fUpLeft        =    info->oPt;
  26.     fUpRight    =     info->above;
  27.     fLwLeft    =    info->left;
  28.     fLwRight    =     info->below;
  29.     this->SetObstacle();
  30.     }
  31.     
  32. // --------------------------------------------------------------------------------------------------
  33. //    TObstacle    :    Draw the obstacle
  34. // --------------------------------------------------------------------------------------------------
  35. void TObstacle::Draw()
  36.     {
  37.     RgnHandle rgn;
  38.  
  39.     PenMode (srcXor);
  40.     PenSize (1,1);
  41.     HLock((Handle) this);
  42.     RGBForeColor(&ObstacleColor);
  43.     HUnlock((Handle) this);
  44.     PenPixPat(ObstaclePat);
  45.  
  46.     rgn = NewRgn();
  47.     OpenRgn();
  48.     MoveTo (fUpLeft->fTrans.h, fUpLeft->fTrans.v);
  49.     LineTo (fUpRight->fTrans.h, fUpRight->fTrans.v);
  50.     LineTo (fLwRight->fTrans.h, fLwRight->fTrans.v);
  51.     LineTo (fLwLeft->fTrans.h, fLwLeft->fTrans.v);
  52.     LineTo (fUpLeft->fTrans.h, fUpLeft->fTrans.v);
  53.     CloseRgn (rgn);
  54.     PaintRgn (rgn);
  55.     DisposeRgn (rgn);
  56.     }
  57.     
  58. // --------------------------------------------------------------------------------------------------
  59. //    TObstacle    :    Release the Points
  60. // --------------------------------------------------------------------------------------------------
  61. void TObstacle::ReleaseObstacle(void)
  62.     {
  63.     fUpLeft->SetObstacle(false,4,NULL);
  64.     fUpRight->SetObstacle(false,3,NULL);
  65.     fLwLeft->SetObstacle(false,2,NULL);
  66.     fLwRight->SetObstacle(false,1,NULL);
  67.     }
  68.     
  69. // --------------------------------------------------------------------------------------------------
  70. //    TObstacle    :    Set the Points
  71. // --------------------------------------------------------------------------------------------------
  72. void TObstacle::SetObstacle(void)
  73.     {
  74.     fUpLeft->SetObstacle(true,4,(TObject *) this);
  75.     fUpRight->SetObstacle(true,3,(TObject *) this);
  76.     fLwLeft->SetObstacle(true,2,(TObject *) this);
  77.     fLwRight->SetObstacle(true,1,(TObject *) this);
  78.     }
  79.     
  80. // --------------------------------------------------------------------------------------------------
  81. //    TObstacle    :    Release the Points
  82. // --------------------------------------------------------------------------------------------------
  83. pascal void TObstacle::Free(void)
  84.     {
  85.     if (fUpLeft->GetObsQuad(4) != NULL)
  86.         this->ReleaseObstacle();
  87.     inherited::Free();
  88.     }
  89.     
  90.